package com.gitee.zhanyao.test.springrestdoc.model;

import java.util.Objects;
import java.util.function.Predicate;


public class Pets {
    private Pets() {
        throw new UnsupportedOperationException();
    }


    public static Predicate<Pet> statusIs(final String status) {
        return new Predicate<Pet>() {
            public boolean test(Pet input) {
                return Objects.equals(input.getStatus(), status);
            }
        };
    }

    public static Predicate<Pet> tagsContain(final String tag) {
        return new Predicate<Pet>() {
            public boolean test(Pet input) {
                return input.getTags().stream().anyMatch(Pets.withName(tag));
            }
        };
    }

    private static Predicate<Tag> withName(final String tag) {
        return new Predicate<Tag>() {
            public boolean test(Tag input) {
                return Objects.equals(input.getName(), tag);
            }
        };
    }
}